package lesson14;

import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;

public class MyCopyOnWriteArrayList {

    public static void main(String[] args) {

        CopyOnWriteArrayList list = new CopyOnWriteArrayList<>(new Integer[]{1,2,3});

        System.out.println(list);

        Iterator<Integer> ite1 = list.iterator();

        list.add(4);

        System.out.println(list);

        Iterator<Integer> ite2 = list.iterator();

        ite1.forEachRemaining(System.out::println);

        ite2.forEachRemaining(System.out::println);

    }
}
